package com.jrx.anytxn.reporting.job.reportingFile.step;

import com.jrx.anytxn.reporting.config.ReportingFileConfig;
import com.jrx.anytxn.reporting.constant.ReportingConstant;
import com.jrx.anytxn.reporting.service.IReportingFileService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustInfoFileWriter implements ItemWriter<String> {

    @Autowired
    private IReportingFileService reportingFileService;

    @Autowired
    private ReportingFileConfig reportingFileConfig;


    @Override
    public void write(List<? extends String> items) throws Exception {
        if(CollectionUtils.isNotEmpty(items)){
            reportingFileService.generatingFile((List<String>) items,reportingFileConfig.getReportingFilePath(),
                    reportingFileConfig.getReportingFileName(), ReportingConstant.REPORTING_FILE_TYPE_CUSTOMER);
        }
    }
}
